﻿@using Mondial2014.Models.Competition
@model List<Mondial2014.Controllers.GameGamblesController.GameGambleViewModel>

@{
    ViewBag.Title = "הימורים";
}

<h2>הימורים עבור @Html.DisplayFor(model => model.First().GamblerName)</h2>

@Html.ActionLink("חזרה לרשימת משתתפים", "Index", "Gamblers")
<br/><br />

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">

        @for (var groupNumber = 0; groupNumber < 8; groupNumber++)
        {
            <h4>בית @(groupNumber + 1)</h4>

            <table class="table">
                <tr>
                    <th>
                        משחק מספר
                    </th>
                    <th>
                        תאריך
                    </th>
                    <th>
                        קבוצה 1
                    </th>
                    <th>
                        קבוצה 2
                    </th>
                    <th>
                        הימור
                    </th>
                    <th></th>
                </tr>

                @for (var gameNumber = (6*groupNumber); gameNumber < (6*groupNumber + 6); gameNumber++)
                {
                    <tr>
                        <td>
                            @Html.TextBox("gameGambleViewModels[" + @gameNumber + "].GameNumber", Model[gameNumber].GameNumber, new { @readonly = "readonly", @style = "display:none" })
                            @Html.TextBox("gameGambleViewModels[" + @gameNumber + "].GamblerId", Model[gameNumber].GamblerId, new { @readonly = "readonly", @style = "display:none" })

                            @Html.DisplayFor(modelItem => Model[gameNumber].GameNumber)
                        </td>
                        <td>
                            @Model[gameNumber].Date.ToString("d.M")
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => Model[gameNumber].Team1)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => Model[gameNumber].Team2)
                        </td>
                        <td>
                            @{ var result = Model[gameNumber].Result; }
                            @if (result == FixtureResult.Team1) { @Html.Label("1") }
                            @if (result == FixtureResult.Team2) { @Html.Label("2") }
                            @if (result == FixtureResult.Tie) { @Html.Label("X") }
                        </td>
                        <td>
                            @if (Model[gameNumber].GamePlayed)
                            {
                                if (Model[gameNumber].CorrectResult == Model[gameNumber].Result)
                                {
                                    <img src="~/Content/images/check.png" alt="" />
                                }
                                else
                                {
                                    <img src="~/Content/images/wrong.png" alt="" />
                                }
                            }
                        </td>
                    </tr>
                }

            </table>
        }

    </div>
}
<div>
    <br />
    @Html.ActionLink("חזרה לרשימת משתתפים", "Index", "Gamblers")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

